{extend name="login/parent" /}
{block name="content"}
<div class="tpl-user-login-main">
    <div class="tpl-user-login-box tpl-user-login-header">
        <h2>{$web_name} 后台</h2>
    </div>
    <div class="tpl-user-login-box tpl-user-login-body">
        <form id="loginForm" action="" class="layui-form" method="post">
            <div class="layui-form-item">
                <label class="tpl-user-login-icon layui-icon layui-icon-username"></label>
                <input type="text" name="keyword" value="{:cookie('remember_name')}" lay-verify="required" placeholder="用户名/手机号" class="layui-input" title="用户名/手机号">
            </div>
            <div class="layui-form-item">
                <label class="tpl-user-login-icon layui-icon layui-icon-password"></label>
                <input type="password" name="user_pwd" value="{:cookie('remember_pwd')}" lay-verify="required" placeholder="密码" class="layui-input" title="密码">
            </div>
            {gt name="'error_num'|cookie" value="2"}
            <div class="layui-form-item">
                <div class="layui-row">
                    <div class="layui-col-xs7">
                        <label class="tpl-user-login-icon layui-icon layui-icon-vercode"></label>
                        <input type="text" name="vercode" lay-verify="required" placeholder="验证码" class="layui-input">
                    </div>
                    <div class="layui-col-xs5">
                        <div style="margin-left: 10px;overflow: hidden;">
                            <img src="" id="cap-src" onclick="this.src='{:captcha_src()}?'+ Math.random();" alt="验证码" />
                        </div>
                    </div>
                </div>
            </div>
            {/gt}
            <div class="layui-form-item">
                <div class="layui-input-inline" style="width: 100%">
                    <span style="vertical-align: middle;display: inline-block;">语言：</span>
                    <input type="radio" name="language" value="1" title="中文" {eq name="'remember_language'|cookie" value="1"} checked {/eq}>
                    <input type="radio" name="language" value="2" title="English" {eq name="'remember_language'|cookie" value="2"} checked {/eq}>
                    <input type="radio" name="language" value="3" title="繁体字" {eq name="'remember_language'|cookie" value="3"} checked {/eq}>
                </div>
            </div>
            <div class="layui-form-item" style="margin-bottom: 20px;">
                <input type="checkbox" name="remember" value="1" lay-skin="primary" title="记住" {eq name="'remember'|cookie" value="1"} checked {/eq}>
                <!--<a href="{:url('forget')}" class="tpl-user-jump-change tpl-link" style="margin-top: 7px;">忘记密码？</a>-->
            </div>
            <div class="layui-form-item">
                <button class="layui-btn layui-btn-fluid" lay-submit lay-filter="loginSubmit">登 录</button>
            </div>
            <!--<div class="layui-trans layui-form-item tpl-user-login-other">-->
                <!--<label>直接进入</label>-->
                <!--<a href="{:url('QQLogin')}"><i class="layui-icon layui-icon-login-qq"></i></a>-->
                <!--<a href="{:url('weChatLogin')}"><i class="layui-icon layui-icon-login-wechat"></i></a>-->
                <!--<a href="{:url('register')}" class="tpl-user-jump-change tpl-link">注册帐号</a>-->
            <!--</div>-->
        </form>
    </div>
</div>
{/block}

{block name="script"}
<script>
    $(function(){
        $(document).ready(function () {
            $('#cap-src').click();
        });

        layui.config({
            version: '2.2.5'
        }).use(['form'],function(){
            var form = layui.form;

            //监听提交
            form.on('submit(loginSubmit)', function (data) {
                $.post('{:url("login")}', $('#loginForm').serialize(), function (result) {
                    if (result.code) {
                        window.location.href = result.url;
                    } else {
                        layer.alert(result.msg, {icon:2, title:'登录失败！'}, function () {
                            window.location.reload();
                        });
                    }
                }, 'json');

                return false;
            });
        });
    });

</script>
{/block}